package com.bs.repository;

import com.bs.domain.AlertSub;
import com.bs.domain.AlertSubQuery;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * Created by wujian
 * Date: 2017-12-12
 * Time: 11:38
 */
public interface AlertSubRepository extends JpaRepository<AlertSub, Long>, JpaSpecificationExecutor<AlertSub> {
//
//    @Query(value = "select s.ID AS id, s.USER_ID AS userId,u.USER_NAME AS userName,s.ALERT_ID AS alertId,s.PARTITION_ID" +
//        " AS partitionId,s.MODULE_NAME AS moduleName,s.MSG_TYPE AS msgType,s.REC_CREATE_TIME AS recCreateTime," +
//        "s.REC_CREATOR AS recCreator from alert_sub s,alert_user u where s.USER_ID=u.USER_ID"
//        , nativeQuery = true)
//    List<AlertSubQuery> findAlertSubInfo();

    @Query(value = "select new com.bs.domain.AlertSubQuery" +
        "(s.id, s.userId, u.userName, s.alertId, s.partitionId, s.moduleName, s.msgType, s.recCreateTime, s.recCreator) " +
        "from AlertSub s,AlertUser u where s.userId=u.userId")
    List<AlertSubQuery> findAlertSubInfo();



}
